﻿package mvc.controller {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import mvc.model.MouseProxy;
	import mvc.model.PalletProxy;
	import mvc.model.ToolProxy;
	import mvc.PainterFacade;
	import mvc.view.PainterMediator;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.command.SimpleCommand;
	import org.puremvc.as3.multicore.patterns.observer.Notification;
    
	public class StartupCommand extends SimpleCommand {
		
		override public function execute(note:INotification):void {
			var facade:PainterFacade = this.facade as PainterFacade;
			var app:Main = note.getBody() as Main;
			
			var viewComponents:Array =
				[
					app.colorPicker_btn, 
					app.pen_btn, 
					app.eraser_btn, 
					app.clear_btn, 
					app.canvas
				];
			
			var mediator:PainterMediator = new PainterMediator(viewComponents);
			
			facade.registerMediator(mediator);
			
			facade.registerProxy(new MouseProxy());
			facade.registerProxy(new PalletProxy(app.colorPicker_btn.selectedColor));
			facade.registerProxy(new ToolProxy(ToolProxy.PEN));
			
			facade.registerCommand(PainterFacade.COLOR_CHANGE, ChangeColorCommand);
			facade.registerCommand(PainterFacade.MOUSE_DOWN, MouseDownCommand);
			facade.registerCommand(PainterFacade.MOUSE_MOVE, MouseMoveCommand);
			facade.registerCommand(PainterFacade.TOOL_CHANGE, ChangeToolCommand);
		}
	}
}